import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../person_detail/models/person_base_model/data.dart';
import 'index.dart';

class PersonPortraitController extends GetxController
    with GetSingleTickerProviderStateMixin {
  PersonPortraitController();

  final state = PersonPortraitState();

  // tap
  void handleTap(int index) {
    Get.snackbar(
      "标题",
      "消息",
    );
  }

  /// 在 widget 内存中分配后立即调用。
  @override
  void onInit() {
    state.leaderId = Get.parameters['id'].toString();
    state.fellow = Get.arguments[0];
    state.alumni = Get.arguments[1];
    state.colleague = Get.arguments[2];

    state.pTitles = [
      '按老乡(${state.fellow.length})',
      '按校友(${state.alumni.length})',
      '按同事(${state.colleague.length})'
    ];
    state.pTc = TabController(length: 3, vsync: this)
      ..addListener(() {
        if (state.pTc.index != state.pTc.previousIndex) {
          update();
        }
      });

    super.onInit();
  }

  /// 在 onInit() 之后调用 1 帧。这是进入的理想场所
  @override
  void onReady() {
    super.onReady();
  }

  /// 在 [onDelete] 方法之前调用。
  @override
  void onClose() {
    super.onClose();
  }

  /// dispose 释放内存
  @override
  void dispose() {
    super.dispose();
  }
}
